﻿using System.Collections.Generic;
using QuizzMe.Pages;

namespace QuizzMe.Helpers
{
    /// <summary>
    /// Helper for models
    /// </summary>
    public static class ModelHelper
    {
        /// <summary>
        /// Get a list of Answer from a given question
        /// </summary>
        public static List<Quizz.Answer> GetAnswers(this QuizzServiceRef.QuizzPart quizzPart)
        {
            List<Quizz.Answer> list = new List<Quizz.Answer>
                                          {
                                              new Quizz.Answer(quizzPart.Question.answer1, quizzPart.Question.goodAnswer == 0x0),
                                              new Quizz.Answer(quizzPart.Question.answer2, quizzPart.Question.goodAnswer == 0x1)
                                          };
            if (quizzPart.Question.answer3 != null)
                list.Add(new Quizz.Answer(quizzPart.Question.answer3, quizzPart.Question.goodAnswer == 0x2));
            if (quizzPart.Question.answer4 != null)
                list.Add(new Quizz.Answer(quizzPart.Question.answer4, quizzPart.Question.goodAnswer == 0x3));
            
            return list;
        }
    }
}
